<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-10-07 12:32:11
 * @LastEditTime: 2019-10-27 22:14:40
 * @LastEditors: Please set LastEditors
 -->
<template>
  <d2-container better-scroll>
    <!-- 头部搜索部分 -->
    <template slot="header">
      <el-form :inline="true" size="mini" style="margin-bottom: -18px;">
          <el-form-item label="姓名:" prop="name">
              <el-input v-model="name" placeholder="姓名" style="width: 140px;"  clearable />
          </el-form-item>

          <el-form-item>
              <el-button type="primary" @click="searchByName">
                  <d2-icon name="search" /> 查询
              </el-button>
          </el-form-item>

          <el-form-item>
              <el-button @click="searchReset">
                  <d2-icon name="refresh" /> 重置
              </el-button>
          </el-form-item>
      </el-form>
    </template>
    <!-- 主体表格 -->
    <userApplicationList :applyList="applyList" :examineDate="true" ref="userApplicationList"/>
    <!-- 尾部页码显示 -->
    <template slot="footer">
      <pagination @getApplyList="getApplyList" :total="total"/>
    </template>
</d2-container>
</template>
 <style lang="scss" scoped>
     .d2-container-full{
       // body表格
       .d2-container-full__body{
         .el-table{
           margin:-20px auto;
           font-size: 16px;
         }
      }
      .el-form{
        margin-left: 10px;
      }
    }
  </style>

<script>
import userApplicationList from '@/components/userApplicationList'
import pagination from '@/components/pagination'
import { getAllUserApplication, searchByName } from '@/api/userApplication'
export default {
  name: 'record-userRecord',
  data () {
    return {
      name: '',
      id: 1,
      current: 1,
      size: 8,
      total: 0,
      applyList: []
    }
  },
  components: {
    pagination,
    userApplicationList
  },
  created () {
    this.getApplyList(this.size, this.current)
  },
  methods: {
    getApplyList (size, current) {
      getAllUserApplication({ pageNum: current, pageSize: size }).then(res => {
        console.log('getAllUserApplication: ', res)
        this.applyList = res.list
        this.total = res.total
        this.$refs.userApplicationList.loading = false
      }).catch(err => {
        console.log('err', err)
      })
    },
    searchByName () {
      searchByName({ pageNum: this.current, pageSize: this.size, name: this.name }).then(res => {
        console.log('searchByName: ', res)
        this.applyList = res.list
        this.total = res.total
      }).catch(err => {
        console.log('err', err)
      })
    },
    searchReset () {
      this.getApplyList(this.size, this.current)
      this.name = ''
    }
  }
}
</script>
